package org.codersz.order.massage;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.tools.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.codersz.product.common.ProductInfoOutput;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ProductInfoReceiver {

    @RabbitListener(queuesToDeclare = @Queue("productInfo"))
    public void proccess(String message) {
        // message 转换成 ProductInfoOutput
        ProductInfoOutput productInfoOutput = JSON.parseObject(message, ProductInfoOutput.class);
        log.info("从队列【{}】接收到消息:{}", "productInfo", productInfoOutput);

        // 储存到redis

    }

}
